package main

import (
	"fmt"
	"github.com/tealeg/xlsx"
)

type Person struct {
	Name  string
	Age   int
	Email string
}

func main() {
	people := []Person{
		{"Alice", 25, "alice@example.com"},
		{"Bob", 30, "bob@example.com"},
		{"Charlie", 35, "charlie@example.com"},
	}

	file := xlsx.NewFile()
	sheet, err := file.AddSheet("People")
	if err != nil {
		panic(err)
	}

	row := sheet.AddRow()
	row.AddCell().SetValue("Name")
	row.AddCell().SetValue("Age")
	row.AddCell().SetValue("Email")

	for _, person := range people {
		row := sheet.AddRow()
		row.AddCell().SetValue(person.Name)
		row.AddCell().SetValue(person.Age)
		row.AddCell().SetValue(person.Email)
	}

	err = file.Save("people.xlsx")
	if err != nil {
		panic(err)
	}

	fmt.Println("Excel file saved successfully.")
}
